import { Rule, RuleType } from '@midwayjs/decorator';
import { CreateApiPropertyDoc } from '@midwayjs/swagger';
import { Expose } from 'class-transformer';

export class CreateUserDto {
  @CreateApiPropertyDoc('用户名称')
  @Rule(RuleType.string().min(2).required())
  @Expose()
  userName: string;

  @CreateApiPropertyDoc('真实姓名')
  @Rule(RuleType.string().min(2).required())
  @Expose()
  name: string;

  @CreateApiPropertyDoc('密码')
  @Rule(RuleType.string().min(2).required())
  @Expose()
  password: string;

  @CreateApiPropertyDoc('用户昵称')
  @Rule(RuleType.string().min(2).required())
  @Expose()
  nickName: string;

  @CreateApiPropertyDoc('用户头像')
  @Rule(RuleType.string().empty('').optional())
  @Expose()
  headImg: string;

  @CreateApiPropertyDoc('联系方式')
  @Rule(RuleType.string().empty('').optional())
  @Expose()
  phone: string;

  @CreateApiPropertyDoc('备注')
  @Rule(RuleType.string().empty('').optional())
  @Expose()
  remark: string;

  @CreateApiPropertyDoc('状态')
  @Rule(RuleType.number().integer().valid(0, 1).optional())
  @Expose()
  status: number;

  @CreateApiPropertyDoc('创建时间')
  @Rule(RuleType.number().integer().valid(0, 1).optional())
  @Expose()
  createDate: Date;
}

@Rule(CreateUserDto)
export class UpdateUserDto extends CreateUserDto {
  @CreateApiPropertyDoc('用户id')
  @Rule(RuleType.number().integer().valid(0, 1).optional())
  @Expose()
  id: number;

  @CreateApiPropertyDoc('更新时间')
  @Rule(RuleType.number().integer().valid(0, 1).optional())
  @Expose()
  updateDate: Date;
}

export class GetUserInfoDao {
  @CreateApiPropertyDoc('用户id')
  @Rule(RuleType.number().integer().required())
  @Expose()
  id: number;
}
